package com.oldroid.apps.getit.provider;

import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;

public class DownloadsContract {
	
	public static final String IDX_DOWNLOADS__CREATED = "idx_donwloads_created";
	
	public static final String IDX_DOWNLOADS__MODIFIED = "idx_donwloads_modified";
	
	public static final String IDX_DOWNLOADS_TAGS__TAG_ID = "idx_downloads_tags__tag_id";
	
	public static final String IDX_DOWNLOADS_TAGS__DOWNLOADS_ID = "idx_downloads_tags__downloads_id";

	
	
	interface DownloadsColumns {
		int COLUMN_INDEX_ID = 0;
		/**
		 * The name of the column where the initiating application can provided
		 * the title of this download. The title will be displayed to the user
		 * in the list of downloads Fragment
		 */
		String FILENAME = "filename";
		int COLUMN_INDEX_FILENAME = 1;
		/**
		 * The name of the column containing the filename where the downloaded
		 * data was actually stored.
		 */
		String URI = "uri";
		int COLUMN_INDEX_URI = 2;
	     /**
         * The timestamp for when the note was created
         * <P>Type: INTEGER (long)</P>
         */
		String CREATED = "created";
		int COLUMN_INDEX_CREATED = 3;
        /**
         * The timestamp for when the note was last modified
         * <P>Type: INTEGER (long)</P>
         */
		String MODIFIED = "modified";
		int COLUMN_INDEX_MODIFIED = 4;
		/**
		 * The name of the column containing the size of the file in bytes.
		 */
		String TOTAL_BYTES = "total_bytes";
		int COLUMN_INDEX_TOTAL_BYTES = 5;
		/**
		 * The column contains the starred value
		 * <P>Type: BOOLEAN </P>
		 */
		String STARRED = "starred";
		int COLUMN_INDEX_STARRED = 6;
		/**
		 * The name of the column containing the boolean value if the file is
		 * deleted
		 **/
		String DELETED = "deleted";
		int COLUMN_INDEX_DELETED = 7;
	}
	
	interface TagsColumns{
		/**The name of the column containing a unique tag. **/
		String TAG = "tag";
		int COLUMN_INDEX_ID = 0;
		int COLUMN_INDEX_TAG = 1;
	}
	
	interface Downloads_Tags_Columns{
		/** The Value of the Tag index **/
		String TAG_ID = "tag_id";
		/** The Value of the Downloads index **/
		String DOWNLOADS_ID = "downloads_id";
		
		int COLUMN_INDEX_ID = 0;
		int COLUMN_INDEX_TAG_ID = 1;
		int COLUMN_INDEX_DOWNLOADS_ID = 2;
	}
	
	interface BookmarksColumns{
		String FILELOCATION = "location";
		String NAME = "name";
	}
	
	public static final String CONTENT_AUTHORITY = "com.oldroid.apps.getit.provider.downloadsprovider"; // must match authority declared in manifest file
		
	private static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
	
	private static final String PATH_DOWNLOADS = "downloads";
	private static final String PATH_TAGS = "tags";
	private static final String PATH_DOWNLOADS_TAGS = "downloads_tags";
	private static final String PATH_BOOKMARKS = "bookmarks";
	private static final String PATH_SEARCH = "search";
//	private static final String PATH_SEARCH_TAGS = "search_tags";
	private static final String PATH_SEARCH_SUGGEST = "search_suggest_query";
//	private static final String PATH_SEARCH_TAGS_SUGGEST = "search_tags_suggest_query";
	
	public static class Downloads implements DownloadsColumns, BaseColumns{
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_DOWNLOADS).build();
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.nimbus.downloads";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.nimbus.downloads";
		
		public static final String DEFAULT_SORT = DownloadsColumns.MODIFIED + " DESC";
		
		public static Uri buildDownloadsUri(long rowId){
			return ContentUris.withAppendedId(CONTENT_URI, rowId);
		}
		
		public static Uri buildStarredUri(){
			return BASE_CONTENT_URI.buildUpon().appendPath(PATH_DOWNLOADS).appendPath(STARRED).build();
		}
	}
	
	public static class Tags implements TagsColumns, BaseColumns{
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_TAGS).build();
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.nimbus.tags";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.nimbus.tags";
		
		public static final String DEFAULT_SORT = TagsColumns.TAG + " ASC";
		
		public static Uri buildTagsUri(long rowId){
			return ContentUris.withAppendedId(CONTENT_URI, rowId);
		}
	}
	
	public static class Downloads_Tags implements Downloads_Tags_Columns, BaseColumns{
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_DOWNLOADS_TAGS).build();
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.nimbus.downloads_tags";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.nimbus.downloads_tags";
		
		public static Uri buildDownloads_TagsUri(long rowId){
			return ContentUris.withAppendedId(CONTENT_URI, rowId);
		}
	}
	
	public static class Bookmarks implements BookmarksColumns, BaseColumns{
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_BOOKMARKS).build();
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.nimbus.bookmarks";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.nimbus.bookmakrs";
		
		public static Uri buildBookmarksUri(long rowId){
			return ContentUris.withAppendedId(CONTENT_URI, rowId);
		}
	}
}
